package org.blog.model;

import org.blog.util.StringHelper;

public class ModelAdvert extends BaseModel implements ValidateModel {

	private String company;
	private String content;
	private String pic;
	private Double weight;
	private Long createTime;

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getPic() {
		return pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}

	public Double getWeight() {
		return weight;
	}

	public void setWeight(Double weight) {
		this.weight = weight;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	@Override
	public boolean validate(ActionType type) {
		if (ActionType.ADD.equals(type)) {
			if (StringHelper.isEmptyTrim(getPic())
					|| StringHelper.isEmptyTrim(getCompany())
					|| getId() == null || getWeight() == null) {
				return false;
			}
		} else if (ActionType.MODIFY.equals(type)) {
			if (StringHelper.isEmptyTrim(getPic()) || getId() == null
					|| getWeight() == null) {
				return false;
			}
		} else if (ActionType.GET.equals(type)) {
			if (getId() == null) {
				return false;
			}
		}
		return true;
	}
}
